<template>

  <div class="app-container">
    <el-form ref="form" :model="carSpace" label-width="120px">
      <el-form-item label="车位号">
        <el-input v-model="carSpace.spaceId" />
      </el-form-item>
      <el-form-item label="车位类型">
        <el-radio-group v-model="carSpace.type">
          <el-radio label="地库"/>
          <el-radio label="地面" />
        </el-radio-group>
      </el-form-item>
      <el-form-item label="运营模式">
        <el-radio-group v-model="carSpace.mode">
          <el-radio label="租赁"/>
          <el-radio label="销售" />
        </el-radio-group>
      </el-form-item>
      <el-form-item label="运营状态">
        <el-select v-model="carSpace.status" placeholder="运营状态">
          <el-option label="正常" value="正常" />
          <el-option label="维修" value="维修" />
          <el-option label="待租" value="待租" />
          <el-option label="待售" value="待售" />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary"  @click="onSubmit">新增车位</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>


    </el-form>
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  data() {
    return {
      carSpace: {
        spaceId: '',
        type: '',
        mode:'',
        status:''
      }
    }
  },
  methods: {
    onSubmit() {
      // 请求接口 实现用户新增接口的调用
      request({
        url:"http://127.0.0.1:8080/api/carSpace/save.do",
        method: "POST",
        data:this.carSpace
      }).then(res=>{
        if(res.code==0){
          //跳转到列表页面
          this.$router.push("/carSpaceList");
        }
      })
    },
    checkPass() {},
    onCancel() {
      this.$message({
        message: '取消车位的新增',
        type: 'warning'
      })
    }
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

